﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Landpy.LogAnalyzer.Log;

namespace Landpy.LogAnalyzer.Configuration
{
    [Serializable]
    public class Setting
    {
        private List<string> columnFilters;
        private List<string> columnHeaderTexts;
        private List<LogColumn> columns;

        public string GlobalFilterStartFlag { get; set; }

        public string GlobalFilterEndFlag { get; set; }

        public LogColumnSchema LogColumnShcema { get; set; }

        [XmlIgnore]
        public List<string> ColumnHeaderTexts
        {
            get
            {
                if (columnHeaderTexts == null)
                {
                    columnHeaderTexts = new List<string>();
                    if (LogColumnShcema != null)
                    {
                        foreach (LogColumn logColumn in LogColumnShcema.Columns)
                        {
                            columnHeaderTexts.Add(logColumn.HeaderText);
                        }
                    }
                }
                return columnHeaderTexts;
            }
        }

        [XmlIgnore]
        public List<LogColumn> Columns
        {
            get
            {
                if (columns == null)
                {
                    columns = new List<LogColumn>();
                    if (LogColumnShcema != null)
                    {
                        foreach (LogColumn logColumn in LogColumnShcema.Columns)
                        {
                            columns.Add(logColumn);
                        }
                    }
                }
                return columns;
            }
        }

        [XmlIgnore]
        public List<string> ColumnFilters
        {
            get
            {
                if (columnFilters == null)
                {
                    columnFilters = new List<string>();
                    if (columnFilters != null)
                    {
                        foreach (LogColumn logColumn in LogColumnShcema.Columns)
                        {
                            columnFilters.Add(logColumn.Filter);
                        }
                    }
                }
                return columnFilters;
            }
        }
    }
}